package com.hzeport.bgs22emduty.inbound.api;

import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
////import com.hzeport.bgs22emduty.entity.DutyScheduleSet;
import com.hzeport.bgs22emduty.service.DutyScheduleSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2022-12-02 11:21:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dutyscheduleset")
@Api(value = "dutyscheduleset", tags = "${comments}管理")
@Slf4j
public class DutyScheduleSetController {

    private final DutyScheduleSetService dutyScheduleSetService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param dutyScheduleSet ${comments}
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public BaseResult getDutyScheduleSetPage(Page page, DutyScheduleSet dutyScheduleSet) {
        return BaseResult.ok(dutyScheduleSetService.page(page, dutyScheduleSet));
    }


    /**
     * 通过id查询${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public BaseResult getById(@PathVariable("id") String id) {
        return BaseResult.ok(dutyScheduleSetService.getById(id));
    }

    /**
     * 新增${comments}
     * @param dutyScheduleSet ${comments}
     * @return R
     */
    @ApiOperation(value = "新增${comments}", notes = "新增${comments}")
    @PostMapping
    public BaseResult save(@RequestBody DutyScheduleSet dutyScheduleSet) {
        return BaseResult.ok(dutyScheduleSetService.save(dutyScheduleSet));
    }

    /**
     * 修改${comments}
     * @param dutyScheduleSet ${comments}
     * @return R
     */
    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
    ////@SysLog(.*)
    @PutMapping
    public BaseResult updateById(@RequestBody DutyScheduleSet dutyScheduleSet) {
        DutyScheduleSet byId = dutyScheduleSetService.getById(dutyScheduleSet.getId());
        if (byId != null) {
            dutyScheduleSet.setRecVersion(byId.getRecVersion());
        }
        return BaseResult.ok(dutyScheduleSetService.updateById(dutyScheduleSet));
    }

    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    //////@SysLog(.*)
    @DeleteMapping("/{id}")
    public BaseResult removeById(@PathVariable String id) {
        return BaseResult.ok(dutyScheduleSetService.removeById(id));
    }

}
